import React from 'react';
import {HashRouter as Router, Route, Switch,Redirect} from 'react-router-dom';
import App from './App';
import Login from "./pages/login";
import Admin from "./admin";
import Buttons from "./pages/ui/buttons";
import NoMatch from "./pages/nomatch";
import Modals from "./pages/ui/modals";
import Loadings from "./pages/ui/loadings";
import Notification from "./pages/ui/notification";
import Messages from "./pages/ui/messages";
import ITabs from "./pages/ui/tabs";
import Gallery from "./pages/ui/gallery";
import Carousels from "./pages/ui/carousel";
import FormLogin from "./pages/form/login";
import FormRegister from "./pages/form/register";
import BasicTable from "./pages/table/basicTable";
import HighTable from "./pages/table/highTable";
import City from "./pages/city";
import Order from "./pages/order";
import Common from "./common";
import OrderDetail from "./pages/order/detail";
import User from "./pages/user";
import Role from "./pages/role";
import Home from "./pages/home";

export default class IRouter extends React.Component {
    render() {
        return (
            <Router>
                <App>
                    <Switch>
                        <Route path="/login" component={Login}/>
                        <Route path="/common" render={() =>
                            <Common>
                                <Route path="/common/order/detail/:orderId" component={OrderDetail}/>
                            </Common>

                        }/>

                        <Route path="/" render={() =>
                            <Admin>
                                <Switch>
                                    <Route path="/home" component={Home}/>
                                    <Route path="/ui/buttons" component={Buttons}/>
                                    <Route path="/ui/modals" component={Modals}/>
                                    <Route path="/ui/loadings" component={Loadings}/>
                                    <Route path="/ui/notification" component={Notification}/>
                                    <Route path="/ui/messages" component={Messages}/>
                                    <Route path="/ui/tabs" component={ITabs}/>
                                    <Route path="/admin/ui/gallery" component={Gallery}/>
                                    <Route path="/ui/carousel" component={Carousels}/>
                                    <Route path="/form/login" component={FormLogin}/>
                                    <Route path="/form/reg" component={FormRegister}/>
                                    <Route path="/table/basic" component={BasicTable}/>
                                    <Route path="/table/high" component={HighTable}/>
                                    <Route path="/city" component={City}/>
                                    <Route path="/order" component={Order}/>
                                    <Route path="/user" component={User}/>
                                    <Route path="/permission" component={Role}/>
                                    <Redirect to="/home"/>
                                    <Route component={NoMatch}/>

                                </Switch>
                            </Admin>
                        }/>

                    </Switch>

                </App>
            </Router>
        );
    }

}
